<?php
namespace app\admin\validate;
use think\Validate;
class Admin extends Validate
{
    //验证规则
    protected $rule = [
        'username'  =>  'require|max:25|unique:admin',
        'password'  =>  'require',
    ];
    //错误提示
    protected $message = [
        'username.require' => '管理员名称必须填写',
        'username.unique'  => '管理员名称不能重复',
        'username.max'     => '管理员名称长度必须小于25位',
        'password.require' => '管理员密码必须填写',
    ];
    //验证场景
    protected $scene = [
        'add'  => ['username'=>'require|unique:admin','password'],//验证username
        'edit' => ['username'=>'require|unique:admin'],//验证username
    ];
}
